package com.example.api.service.impl;

import com.example.api.dao.InventoryDao;
import com.example.api.model.entity.Inventory;
import com.example.api.model.support.RespBean;
import com.example.api.service.InventoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class InventoryServiceImpl implements InventoryService {

    @Resource
    private InventoryDao inventoryDao;

    @Override
    public RespBean save(Inventory inventory) {
        if (inventoryDao.insertSelective(inventory) > 0) {
            return RespBean.success("添加成功");
        }
        return RespBean.error("添加失败");
    }

    @Override
    public List<Inventory> findAll() {
        return inventoryDao.findAll();
    }

    @Override
    public List<Inventory> findByCommodityId(Integer cid) {
        return inventoryDao.findAllByCid(cid);
    }

    @Override
    public List<Inventory> findByWarehouseId(Integer wid) {
        return inventoryDao.findAllByWid(wid);
    }

}